# Maintainer: Andrew Sun <adsun701@gmail.com>

_pyname=PrettyTable
_realname=prettytable
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.0.0
pkgrel=1
pkgdesc="A simple Python library for easily displaying tabular data (mingw-w64)"
arch=('any')
url="https://pypi.python.org/pypi/PrettyTable"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
         "${MINGW_PACKAGE_PREFIX}-python-wcwidth")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools-scm")
options=('staticlibs' 'strip' '!debug')
_dtoken=dc2e9370bf3be766302dbd6cd9729e258e875d31a7a21c9f760aaa5b5b5e
source=("${_realname}-${pkgver}.tar.gz::https://files.pythonhosted.org/packages/source/P/PrettyTable/${_realname}-${pkgver}.tar.gz"
        "0001-Fix-column-spacing-with-xterm-reset-escape-sequence.patch")
sha256sums=('e37acd91976fe6119172771520e58d1742c8479703489321dc1d9c85e7259922'
            '81d3d904b6a692121bc5f96bc3e3b47e000660c146a093d46529cbde43395c9e')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/0001-Fix-column-spacing-with-xterm-reset-escape-sequence.patch"

  cd "${srcdir}"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
}
